home *** CD-ROM | disk | FTP | other *** search
- {
- File: SaveAPrintRecord.p
-
- Contains: Save a Print Record: Walks you through the style and job dialogs to create a
- print record ready-to-print-with, and then saves it to a resource file with
- resource type 'YO!!' and ID 128. The first step towards saving print records
- for multiple printers so you can set your favorite parameters before printing,
- since there's no API to do most of it.
-
- Written by:
-
- Copyright: Copyright © 1999 by Apple Computer, Inc., All Rights Reserved.
-
- You may incorporate this Apple sample source code into your program(s) without
- restriction. This Apple sample source code has been provided "AS IS" and the
- responsibility for its operation is yours. You are not permitted to redistribute
- this Apple sample source code as "Apple sample source code" after having made
- changes. If you're going to re-distribute the source, we require that you make
- it clear in the source that the code was descended from Apple sample source
- code, but that you've made changes.
-
- Change History (most recent first):
- 7/26/1999 Karl Groethe Updated for Metrowerks Codewarror Pro 2.1
-
-
- }
-
- {------------------------------------------------------------------------------}
-
-
- {$I-}
- program Sample;
-
-
- uses
- Traps, Printing, StandardFile,Fonts,Quickdraw,Menus,TextEdit,Dialogs,Resources,Sound;
-
- procedure Initialize;
-
- var
- ignoreResult: BOOLEAN;
- ourPrintRecord: THPrint;
- ourReply: StandardFileReply;
- ourOSErr: OSErr;
- ourResRefNum: integer;
-
-
- begin
- InitGraf(@qd.thePort);
- InitFonts;
- InitWindows;
- InitMenus;
- TEInit;
- InitDialogs(nil);
- InitCursor;
-
- PrOpen;
- ourPrintRecord := THPrint(NewHandle(SIZEOF(TPrint)));
- PrintDefault(ourPrintRecord);
- ignoreResult := PrStlDialog(ourPrintRecord);
- ignoreResult := PrJobDialog(ourPrintRecord);
-
- StandardPutFile('Save print record file as', 'My Print Record', ourReply);
- ourOSErr := noErr;
- if ourReply.sfGood then {Did the user accept a file to save as?}
- begin
- if ourReply.sfReplacing then
- ourOSErr := FSpDelete(ourReply.sfFile); { make sure this is gone before we start! }
- if ourOSErr = noErr then
- begin
- FSpCreateResFile(ourReply.sfFile, 'RSED', 'RSRC', ourReply.sfScript);
- ourResRefNum := FSpOpenResFile(ourReply.sfFile, fsWrPerm);
- AddResource(Handle(ourPrintRecord), 'YO!!', 128, 'Saved print record');
- CloseResFile(ourResRefNum);
- end
- else
- SysBeep(10);
- end;
- end;
-
-
- begin
-
- {1.01 - call to ForceEnvirons removed}
- {If you have stack requirements that differ from the default,}
- { then you could use SetApplLimit to increase StackSpace at }
- { this point, before calling MaxApplZone.}
-
- MaxApplZone; {expand the heap so code segments load at the top}
-
- Initialize; {initialize the program}
- ExitToShell;
- end.